package org.duiduo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.duiduo.entity.Book;

public interface BookMapper extends BaseMapper<Book> {

    // 数据库排它锁 扣减库存 防止超卖
    @Update("update book set count = count - #{count} where id = #{id} and count > (0 + #{count})")
    void buyAbatementCount(@Param("id") Integer id, @Param("count") Integer count);
}
